<link rel="stylesheet" href="<?php echo css_url('calendrier' )?>" type="text/css" media="screen" />

<script type ="text/javascript" src="<?php echo js_url('jquery') ?>"></script>
<script type ="text/javascript" src="<?php echo js_url('javascriptFonctions') ?>"></script>
<script type ="text/javascript" src="<?php echo js_url('jquery') ?>"></script>
<script type ="text/javascript" src="<?php echo js_url('calendrier') ?>"></script>

<h2>Fiche bilan de l'action</h2>
<form id="form_ficheBilanAction" action='<?php echo base_url();?>index.php/FichesAction/<?php echo $action.'/'.$idAction;?>' method='post'>

	<?php 
	if($adc->getGroupable() == 0)
	{
		$i=1;
		echo '	
			<table id="table_tache">
				<tr>
					<th>
						Tâches réalisées
					</th>
					<th>
						Echéance
					</th>
					<th>
						Responsable
					</th>
					<th  class="BPlus">
						<input type="button" name="Plus" value="+" onClick="ajoutTache()"/>
					</th>
				</tr>';
		if(!empty($tache))
		{
			foreach($tache as $t)
			{
				echo'
					<tr>
						<td class="TabT">
							<input type="text" name="TacheRealise[]" class="champ"';
								 if(isset($t))
										echo 'value ="'.$t->getLibelle().'"';
									echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
								
							echo '>
						</td>
						<td class="TabT">				
							<input type="text" name="Echeance[]" class="calendrier"';
							 if(isset($t))
									echo 'value ='.putDateJJMMAAAA($t->getEcheance());
								echo ' placeholder="jj/mm/aaaa" onBlur="verifChamp(this)" onFocus="blanc(this)"';
							echo'>
						</td>
						<td class="TabT">
							<div id="for">
							<select class="champ" name="Responsable[]">';
								foreach($etudiants as $etu)
								{
									echo '<option ';
									if(isset($t))
									{
										if($etu->getId() == $t->getIdEtudiant())
											echo 'selected="selected"';
									}
									echo 'value="'.$etu->getId().'">'.$etu->getNom().' '.$etu->getPrenom().'</option>';
								}
								echo'</select>';
							
						echo'</div>
						</td>';
						if($i != 1)
							echo'<td class="BMoins"><input type="button" value="-" onClick="enleveLigne(this,\'table_tache\')"/></td>';
						else
							echo'<td>	</td>';
						echo '</tr>';
						
						$i++;
			}
		}
		else 
		{
			echo '<tr>
						<td class="TabT">
							<input type="text" name="TacheRealise[]" class="champ"
									 onBlur="verifChamp(this)" onFocus="blanc(this)">
						</td>
						<td class="TabT">				
							<input type="text" name="Echeance[]" class="calendrier"
									 onBlur="verifChamp(this)" onFocus="blanc(this)"  placeholder="jj/mm/aaaa" 	>
						</td>
						<td class="TabT">
							<div id="for">
							<select class="champ" name="Responsable[]">';
								foreach($etudiants as $etu)
								{
									echo '<option value="'.$etu->getId().'">'.$etu->getNom().' '.$etu->getPrenom().'</option>';
								}
								echo'</select>';
							
						echo'</div>
						</td>
						<td></td>
				</tr>';
		}
					echo'
	 			<tr  id="ajoutTache">
	 			</tr>
			</table>
		
		<p>
			<h4>Dépenses</h4><hr/>
		</p>
		<table id="table_depense">
			<tr>
				<th>
					Nature
				</th>
				<th>
					Budgets
				</th>
				<th>
					Fournisseur
				</th>
				<th class="BPlus">
					<input type="button" name="Plus" value="+" onClick="ajoutDepense()"/>
				</th>
			</tr>';
			if(!empty($depense))
			{
				foreach($depense as $d)
				{
					echo'<tr>
						<td>
							<input type="text" name="NatureDepense[]" class="champ"';
							 if(isset($d))
									echo ' value = "'.$d->getLibelle().'"';
								echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
			
						echo'/>
						</td>
						<td>
							<input type="text" name="BudgetDepense[]" class="champ"';
							 if(isset($d))
									echo ' value = "'.$d->getBudget().'"';
								echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
						echo'/>
						</td>
						<td>
							<input type="text" name="Fournisseur[]" class="champ"';
							if(isset($d))
									echo ' value = "'.$d->getFournisseur().'"';
								echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
						echo'/>
						</td>
						<td class="BMoins">
								<input type="button" value="-" onClick="enleveLigne(this,\'table_depense\')"/>
						</td>';
					
				}
			}
			else 
			{
				echo'<tr>
						<td>
							<input type="text" name="NatureDepense[]" class="champ"
							 		onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						</td>
						<td>
							<input type="text" name="BudgetDepense[]" class="champ"
							 		 onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						</td>
						<td>
							<input type="text" name="Fournisseur[]" class="champ"
							 		 onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						</td>
						<td class="BMoins">
								<input type="button" value="-" onClick="enleveLigne(this,\'table_depense\')"/>
						</td>';
			}
			
		echo'
				</tr>
				<tr  id="ajoutDepense">
				</tr>
			</table>
		
		</p>
			<h4>Recettes</h4><hr/>
		<p>
		<table id="table_recette">
			<tr>
				<th>
					Nature
				</th>
				<th>
					Budgets
				</th>
				<th class="BPlus">
					<input type="button" name="Plus" value="+" onClick="ajoutRecette()"/>
				</th>
			</tr>';
		if(!empty($recette))
		{
			foreach($recette as $r)
			{
				echo'
					<tr>
						<td>
							<input type="text" name="NatureRecette[]" class="champ"';
								if(isset($r))
									echo ' value = "'.$r->getLibelle().'"';
							
								echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
						echo'/>
						</td>
						<td>
							<input type="text" name="BudgetRecette[]" class="champ"';
								if(isset($r))
									echo ' value ='.$r->getBudget();
							
								echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"';
							echo'/>
						</td>
						<td class="BMoins">
							<input type="button" value="-" onClick="enleveLigne(this,\'table_recette\')"/>
						</td>
					</tr>';
			}
		}
		else 
		{
			echo'
					<tr>
						<td>
							<input type="text" name="NatureRecette[]" class="champ"
											 onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						</td>
						<td>
							<input type="text" name="BudgetRecette[]" class="champ"
											onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						</td>
						<td class="BMoins">
							<input type="button" value="-" onClick="enleveLigne(this,\'table_recette\')"/>
						</td>
					</tr>';
		}
			
		echo'
		<tr  id="ajoutRecette">
		</tr>
		</table>';
		
	}
	else 
	{
		echo'
			<h4>Travail effectué</h4>
			<p>
				<textarea name="TravailEffectue" cols="100" rows="10">';if(isset($fba)) echo $fba->getTravailEffectue();
				echo'</textarea>
			</p>';
	}
		
		
		?>
	
	
	
	<h4>Points positifs</h4><hr/>
	<p>
		<textarea name="PointPositif" cols="100" rows="10"><?php if(isset($fba)) echo $fba->getPointPositif();?></textarea>
	</p>
	<h4>Points négatifs</h4><hr/>
	<p>
		<textarea name="PointNegatif" cols="100" rows="10"><?php if(isset($fba)) echo $fba->getPointNegatif(); ?></textarea>
	</p>
	<h4>Bon à savoir</h4><hr/>
	<p>
		<textarea name="BonASavoir" cols="100" rows="10"><?php if(isset($fba)) echo $fba->getBonASavoir(); else echo 'Astuces, personnes ressources...';?></textarea>
	</p>
	<h4>Suggestions</h4><hr/>
	<p>
		<textarea name="Suggestion" cols="100" rows="10"><?php if(isset($fba))echo $fba->getSuggestion();?></textarea>
	</p>
	<p>
		<span id="erreur"></span>
	</p>
	<p>
		<div class="boutons">
			<ul>
				<li><input class="Ligne2" type="submit" value="Envoyer" name="envoyerFicheADC" onClick = "return verifFormulaire()"/></li>
				<li><a href="javascript:history.go(-1)"><button type="button">Retour</button></a></li>
			</ul>
		</div>
	</p>
</form>